package util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class PurchaseNoUtil {
    public static String randomOrderCode() {
        SimpleDateFormat dmDate = new SimpleDateFormat("yyMMddss");
        String randata = getRandom(5);
        Date date = new Date();
        String dateran = dmDate.format(date);
        String code = "PN" + dateran + randata;
        return code;
    }

    public static String getRandom(int len) {
        Random r = new Random();
        StringBuilder rs = new StringBuilder();
        for (int i = 0; i < len; i++) {
            rs.append(r.nextInt(10));
        }
        return rs.toString();
    }

    public static void main(String[] args) {
        System.out.println(randomOrderCode());
    }
}
